package com.qding.park.manager.app.queue.handle;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONObject;
import com.qding.park.common.core.exceptions.BaseException;
import com.qding.park.common.core.redis.SerializeUtils;
import com.qding.park.manager.facade.queue.service.EventWriteBack;
import com.qding.park.manager.facade.queue.service.ReportFacade;
import com.qding.park.manager.pojo.ap.ApAppearanceRecord;
import com.qding.park.manager.pojo.queue.QueueMsg;

/**
  * @ClassName: ReserveDelayTimeoutHandle
  * @Description:车辆出场消息上报  出场记录包括线下缴费单
  * @author Comsys-Administrator
  * @date 2016年10月20日 上午10:10:31
  *
  */
@Component("carOutckeckHandle")
public class CarOutckeckHandle extends AbstractReportHandle{
	
	
    @Autowired
    private ReportFacade  reportFacade;
	
	/**
	 * 事件回写
	 */
	@Autowired
	private  EventWriteBack eventWriteBack;
	
	@Override
	void actualHandle(QueueMsg msg) throws BaseException {
		JSONObject data = (JSONObject) msg.getData();
		ApAppearanceRecord record=SerializeUtils.unSerialize(data.toJSONString(), ApAppearanceRecord.class);
		reportFacade.Park_ParkOutSync(record);//进出场记录
		
		//回写事件  回写mongodb(临停缴费) 及　mysql(临停缴费)
		eventWriteBack.Park_ParkOutSync(record);//缴费记录
	}

	@Override
	boolean failDiscardRollBacK(QueueMsg msg) {
		_log.error("车辆出场消息上报回滚:"+msg);
		return true;
	}
	
}
